package com.shiva.oms.logview.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.logging.Level;

public class LogData implements Serializable {

    private static final long serialVersionUID = -2896759475612130817L;
    private int id;
    private Date date; // = new Date()
    private Level level = Level.INFO;
    private String clazz = "";
    private String method = "";
    private String file = "";
    private String line = "";
    private String ndc = "";
    private String thread = "";
    private String message = "";

    private boolean marked;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Level getLevel() {
        return level;
    }

    public void setLevel(Level level) {
        this.level = level;
    }

    public String getClazz() {
        return clazz;
    }

    public void setClazz(String clazz) {
        this.clazz = clazz;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public String getLine() {
        return line;
    }

    public void setLine(String line) {
        this.line = line;
    }

    public String getNdc() {
        return ndc;
    }

    public void setNdc(String ndc) {
        this.ndc = ndc;
    }

    public String getThread() {
        return thread;
    }

    public void setThread(String thread) {
        this.thread = thread;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isMarked() {
        return marked;
    }

    public void setMarked(boolean marked) {
        this.marked = marked;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        LogData logData = (LogData) o;
        if (id != logData.id)
            return false;
        if (marked != logData.marked)
            return false;
        if (clazz != null ? !clazz.equals(logData.clazz) : logData.clazz != null)
            return false;
        if (date != null ? !date.equals(logData.date) : logData.date != null)
            return false;
        if (file != null ? !file.equals(logData.file) : logData.file != null)
            return false;
        if (level != null ? !level.equals(logData.level) : logData.level != null)
            return false;
        if (line != null ? !line.equals(logData.line) : logData.line != null)
            return false;
        if (message != null ? !message.equals(logData.message) : logData.message != null)
            return false;
        if (method != null ? !method.equals(logData.method) : logData.method != null)
            return false;
        if (ndc != null ? !ndc.equals(logData.ndc) : logData.ndc != null)
            return false;
        return !(thread != null ? !thread.equals(logData.thread) : logData.thread != null);
    }

  @Override
  public int hashCode() {
    int result = date != null ? date.hashCode() : 0;
    result = 31 * result + (level != null ? level.hashCode() : 0);
    result = 31 * result + (clazz != null ? clazz.hashCode() : 0);
    result = 31 * result + (method != null ? method.hashCode() : 0);
    result = 31 * result + (file != null ? file.hashCode() : 0);
    result = 31 * result + (line != null ? line.hashCode() : 0);
    result = 31 * result + (ndc != null ? ndc.hashCode() : 0);
    result = 31 * result + (thread != null ? thread.hashCode() : 0);
    result = 31 * result + (message != null ? message.hashCode() : 0);
    result = 31 * result + id;
    result = 31 * result + (marked ? 1 : 0);
    return result;
  }



    public String toText(){
        return this.id+","+this.level.toString()+","+this.thread+","+this.file+","+this.line+","+this.ndc+","+this.clazz+","+this.method+","+this.message;
    }

    @Override
  public String toString() {
    String builder = "LogData [date=" + date + ", level=" + level + ", clazz=" + clazz +
      ", method=" + method + ", file=" + file + ", line=" + line + ", ndc=" + ndc + ", thread=" +
      thread + ", message=" + message + ", id=" + id + ", marked=" + marked + "]";
    return builder;
  }

//  private String toString(Collection<?> collection, int maxLen) {
//    StringBuilder builder = new StringBuilder();
//    builder.append("[");
//    int i = 0;
//    for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
//      if (i > 0)
//        builder.append(", ");
//      builder.append(iterator.next());
//    }
//    builder.append("]");
//    return builder.toString();
//  }

}
